# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=spice-protocol
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.14.3
pkgrel=3
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="SPICE protocol headers (mingw-w64)"
options=('strip' 'staticlibs')
license=("BSD")
url="https://www.spice-space.org/"
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=(https://www.spice-space.org/download/releases/${_realname}-${pkgver}.tar.xz{,.sig})
validpgpkeys=('206D3B352F566F3B0E6572E997D9123DE37A484F')
sha256sums=('f986e5bc2a1598532c4897f889afb0df9257ac21c160c083703ae7c8de99487a'
            'SKIP')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
}

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype=plain \
    --default-library=both \
    "../${_realname}-${pkgver}"
  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  DESTDIR="${pkgdir}" ninja install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}"/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
